package com.heima.config;

import com.heima.file.impl.MinIOFileStorageService;
import com.heima.properties.MinioProperties;
import io.minio.MinioClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@EnableConfigurationProperties(MinioProperties.class)
@Import(MinIOFileStorageService.class)
public class MinioAutoConfiguration {

    @Bean
    public MinioClient minioClient(MinioProperties properties) {
        return MinioClient.builder()
                // 认证凭据，用户名和密码
                .credentials(properties.getAccessKey(), properties.getSecretKey())
                // 服务地址
                .endpoint(properties.getEndpoint())
                .build();
    }
}
